<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>添加用户</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet">

    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <!-- 4. 导入bootstrap日期控件js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap-datetimepicker.min.js?ver=0.123"></script>
    <script src="${pageContext.request.contextPath}/js/bootstrap-datetimepicker.zh-CN.js?ver=0.123"></script>


</head>
<body>
<div class="container">
    <center><h3>添加员工信息</h3></center>
    <div class="row">
        <div class="col-lg-3"></div>
        <div class="col-lg-6">
            <form action="${pageContext.request.contextPath}/employee/save" method="post">
                <div class="form-group">
                    <label for="e_no">员工编号：</label>
                    <input type="text" class="form-control" id="e_no" name="e_no" placeholder="请输入员工编号">
                </div>
                <div class="form-group">
                    <label for="e_name">员工姓名：</label>
                    <input type="text" class="form-control" id="e_name" name="e_name" placeholder="请输入员工姓名">
                </div>
                <div class="form-group">
                    <label for="dept_id">部门：</label>
                    <select class="form-control" id="dept_id" name="dept_id">

                    </select>
                </div>
                <div class="form-group">
                    <label for="e_section_id">职位：</label>
                    <select class="form-control" id="e_section_id" name="e_section_id">

                    </select>
                </div>
                <div class="form-group">
                    <label for="e_entrytime">入职时间：</label>
                    <input type="text" class="form-control" id="e_entrytime" name="e_entrytime" readonly="readonly"/>
                </div>
                <div class="form-group">
                    <label for="e_tel">联系方式：</label>
                    <input type="text" class="form-control" id="e_tel" name="e_tel" placeholder="请输入联系方式">
                </div>
                <div class="form-group" style="text-align: center">
                    <input class="btn btn-primary" type="submit" value="提交"/>
                    <input class="btn btn-default" type="reset" value="重置"/>
                    <input class="btn btn-default" type="button" onclick="history.go(-1)" value="返回"/>
                </div>
            </form>
        </div>
        <div class="col-lg-3"></div>
    </div>
</div>
</body>
<script type="text/javascript">
    $(function () {
        $('#e_entrytime').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',//日期格式
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0
        });

        $.ajax({
            type: 'POST',
            url: '${pageContext.request.contextPath}/dept/findAll',
            data : {},
            contentType : 'application/json;charset=utf-8',
            success: function (resp) {
                if(resp.length!=0){
                    var html='';
                    for (let i = 0; i < resp.length; i++) {
                        html+='<option value="'+resp[i].dept_id+'">'+resp[i].dept_name+'</option>'
                    }
                    $('#dept_id').html(html);
                }
            }
        });

        $.ajax({
            type: 'POST',
            url: '${pageContext.request.contextPath}/section/findAll',
            data : {},
            contentType : 'application/json;charset=utf-8',
            success: function (resp) {
                if(resp.length!=0){
                    var html='';
                    for (let i = 0; i < resp.length; i++) {
                        html+='<option value="'+resp[i].section_id+'">'+resp[i].section_name+'</option>'
                    }
                    $('#e_section_id').html(html);
                }
            }
        });
    });
</script>
</html>